package com.wang.di.defalut.anno_executor;

import com.wang.di.core.handler.AnnoHandler;
import com.wang.di.core.handler.JustMethodProxy;
import com.wang.di.defalut.anno.LogTs;

import java.lang.reflect.Method;

public class LogTsExecutor extends AnnoHandler<LogTs> {
    @Override
    public JustMethodProxy method(Object instance, Class<?> clz, Method method, LogTs anno) throws Exception {
        return new JustMethodProxy() {
            @Override
            public void pre(Method method, Class<?> clz, Object instance, Object[] args) throws Exception {
                System.out.println("log ts pre: " + System.currentTimeMillis());
            }

            @Override
            public Object after(Method method, Class<?> clz, Object instance, Object[] args, Object result) throws Exception {
                System.out.println("log ts after: " + System.currentTimeMillis());
                return result;
            }
        };
    }
}
